#include<bits/stdc++.h>
using namespace std;
const int N=3001;
int T,n,m,L,V,d[N],v[N],a[N],p[N],f=0,ans=0,num=0;
bool b[N];
void dfs(int k)
{
    if(f==1)return;
    if(k==0)
    {
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            bool flag=0;
            for(int j=1;j<=m;j++)
            if(p[j]>=d[i]&&b[j]!=0)
            {
                int x=sqrt((p[j]-d[i])*2*a[i]+v[i]*v[i]);
                if(x>V)flag=1;
            }
            if(flag)sum++;
            if(sum==num)ans=1,f=1;
        }
    }
    for(int i=1;i<=m;i++)
    if(b[i])
    {
        b[i]=0;
        dfs(k-1);
        b[i]=1;
    }
    return;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        for(int i=1;i<=m;i++)b[i]=1;
        for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=1;i<=n;i++)
        {
            bool flag=0;
            for(int j=1;j<=m;j++)
            if(p[j]>=d[i])
            {
                int x=sqrt((p[j]-d[i])*2*a[i]+v[i]*v[i]);
                if(x>V)flag=1;
            }
            if(flag)num++;
        }
        cout<<num;
        for(int i=m;i>=1;i--)
        {
            f=0;
            dfs(i);
            if(ans!=0)
               {
                   ans=i;break;
               }
        }
        cout<<" "<<ans<<endl;
    }
    return 0;
}
